/* eslint no-unused-vars:0 */
import React from 'react';
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';
import App from './App';
import Login from './../src/pages/login/index';
import Admin from './../src/Admin';

//我校动态 他校动态通用组件
import Download from '@components/Download/index';
import AdvancedSearch from './pages/OthersSituation/OPoliticalRisks/AdvancedSearch';
import AsyncComponent from '@components/AsyncComponent';
import OurSchoolSituation from './../src/pages/OurSchoolSituation';

import OthersSituation from './../src/pages/OthersSituation';
import OOverview from './pages/OthersSituation/OOverview/index';
import OPoliticalRisks from './../src/pages/OthersSituation/OPoliticalRisks/index';
import OReputationalRisks from './../src/pages/OthersSituation/OReputationalRisks/index';
import OSafetyRisks from './../src/pages/OthersSituation/OSafetyRisks/index';
import OSchoolLeaderRisks from './../src/pages/OthersSituation/OSchoolLeaderRisks/index';

import PublicOpinionReport from './pages/PublicOpinionReport';
import CaseAnalysis from './pages/PublicOpinionReport/CaseAnalysis';
import MonographicStudy from './pages/PublicOpinionReport/MonographicStudy';
import PublicOpinionDynamic from './pages/PublicOpinionReport/PublicOpinionDynamic';

import NoMatch from './../src/pages/Nomatch/index';
import RiskAssessment from './pages/RiskAssessment';
import EmergencyPlan from './pages/RiskAssessment/EmergencyPlan/index';
import Solution from './pages/RiskAssessment/Solution';

import Customize from './pages/SelfCheckingSystem/Customize';
import Questionnaire from './pages/SelfCheckingSystem/Questionnaire';

import Admissions from './pages/SpecialCustomized/Admissions';
import Application from './pages/SpecialCustomized/Application';
import Assess from './pages/SpecialCustomized/Assess';
import RiskSelfTest from './pages/SpecialCustomized/RiskSelf-test';

import PermissionSetting from './pages/Settings/PermissionSetting';

import PublicSentiment from './pages/Backmanage/PublicOpinionReportManage/PublicSentiment/PublicSentiment';
import Report from './pages/Backmanage/PublicOpinionReportManage/Report/Report';
import ReportFile from './pages/Backmanage/PublicOpinionReportManage/ReportFile/ReportFile';
import SentimentUser from './pages/Backmanage/PublicOpinionReportManage/SentimentUser/SentimentUser';

import QuestionnaireManage from './pages/Backmanage/QuestionnaireManage';
import RiskAssessmentManage from './pages/Backmanage/RiskAssessmentManage';
import UserManage from './pages/Backmanage/UserManage/adminPage/adminPage';
import Result from './pages/SelfCheckingSystem/Result/index';

import PersonalCenter from './pages/PersonalCenter';

import NullPage from './pages/OthersPages/NullPage';
import Overview from './pages/OurSchoolSituation/Overview';
import PoliticalRisks from './pages/OurSchoolSituation/PoliticalRisks';
import SafetyRisks from './pages/OurSchoolSituation/SafetyRisks';
import ReputationalRisks from './pages/OurSchoolSituation/ReputationalRisks';
import SchoolLeaderRisks from './pages/OurSchoolSituation/SchoolLeaderRisks';
const routes = [
    {
        path: '/admin/OurSchoolSituation',
        componentPath: './pages/OurSchoolSituation/index.js',
        name: 'OurSchoolSituation'
    }
];

export default class RouterJS extends React.Component {
    handleComponent = (path) => {
        console.log(path);
        return AsyncComponent(() => import(`${path}`));
    };
    render() {
        return (
            <HashRouter>
                <App>
                    <Route
                        path="/Admin"
                        render={() => (
                            <Admin history={this.props.history}>
                                <Switch>
                                    {routes.map((page) => (
                                        <Route
                                            path={page.path}
                                            render={() => {
                                                const C = this.handleComponent(
                                                    page.componentPath
                                                );
                                                return <C name={page.name} />;
                                            }}
                                        />
                                    ))}
                                    <Route
                                        path="/admin/OthersSituation"
                                        render={() => (
                                            <OthersSituation>
                                                <Route
                                                    exact
                                                    path="/admin/OthersSituation/"
                                                    component={OOverview}
                                                />
                                                <Route
                                                    path="/admin/OthersSituation/OOverview"
                                                    component={OOverview}
                                                />
                                                <Route
                                                    path="/admin/OthersSituation/OPoliticalRisks"
                                                    component={OPoliticalRisks}
                                                />
                                                <Route
                                                    path="/admin/OthersSituation/OSafetyRisks"
                                                    component={OSafetyRisks}
                                                />
                                                <Route
                                                    path="/admin/OthersSituation/OReputationalRisks"
                                                    component={
                                                        OReputationalRisks
                                                    }
                                                />
                                                <Route
                                                    path="/admin/OthersSituation/OSchoolLeaderRisks"
                                                    component={
                                                        OSchoolLeaderRisks
                                                    }
                                                />
                                            </OthersSituation>
                                        )}
                                    />
                                    {/*<Route component={NoMatch} />*/}
                                    <Route
                                        path="/admin/RiskAssessment"
                                        render={() => (
                                            <RiskAssessment>
                                                <Route
                                                    exact
                                                    path="/admin/RiskAssessment/"
                                                    component={EmergencyPlan}
                                                />
                                                <Route
                                                    path="/admin/RiskAssessment/EmergencyPlan"
                                                    component={EmergencyPlan}
                                                />
                                                <Route
                                                    path="/admin/RiskAssessment/Solution"
                                                    component={Solution}
                                                />
                                            </RiskAssessment>
                                        )}
                                    />
                                    <Route
                                        path="/admin/PublicOpinionReport"
                                        render={() => (
                                            <PublicOpinionReport>
                                                <Route
                                                    exact
                                                    path="/admin/PublicOpinionReport/"
                                                    component={
                                                        PublicOpinionDynamic
                                                    }
                                                />
                                                <Route
                                                    exact
                                                    path="/admin/PublicOpinionReport/PublicOpinionDynamic"
                                                    component={
                                                        PublicOpinionDynamic
                                                    }
                                                />
                                                <Route
                                                    path="/admin/PublicOpinionReport/CaseAnalysis"
                                                    component={CaseAnalysis}
                                                />
                                                <Route
                                                    path="/admin/PublicOpinionReport/MonographicStudy"
                                                    component={MonographicStudy}
                                                />
                                            </PublicOpinionReport>
                                        )}
                                    />
                                    <Route
                                        path="/admin/SelfCheckingSystem/Questionnaire"
                                        component={Questionnaire}
                                    />
                                    <Route
                                        path="/admin/SelfCheckingSystem/Customize"
                                        component={Customize}
                                    />
                                    <Route
                                        path="/admin/SelfCheckingSystem/Result"
                                        component={Result}
                                    />
                                    <Route
                                        path="/admin/SpecialCustomized/Admissions"
                                        component={Admissions}
                                    />
                                    <Route
                                        path="/admin/SpecialCustomized/Application"
                                        component={Application}
                                    />
                                    <Route
                                        path="/admin/SpecialCustomized/Assess"
                                        component={Assess}
                                    />
                                    <Route
                                        path="/admin/SpecialCustomized/RiskSelf-test"
                                        component={RiskSelfTest}
                                    />
                                    <Route
                                        path="/admin/Settings/PermissionSetting"
                                        component={PermissionSetting}
                                    />
                                    <Route
                                        path="/admin/Backmanage/PublicOpinionReportManage/PublicSentiment"
                                        component={PublicSentiment}
                                    />
                                    <Route
                                        path="/admin/Backmanage/PublicOpinionReportManage/Report"
                                        component={Report}
                                    />
                                    <Route
                                        path="/admin/Backmanage/PublicOpinionReportManage/ReportFile"
                                        component={ReportFile}
                                    />
                                    <Route
                                        path="/admin/Backmanage/PublicOpinionReportManage/SentimentUser"
                                        component={SentimentUser}
                                    />
                                    <Route
                                        path="/admin/Backmanage/QuestionnaireManage"
                                        component={QuestionnaireManage}
                                    />
                                    <Route
                                        path="/admin/Backmanage/RiskAssessmentManage"
                                        component={RiskAssessmentManage}
                                    />
                                    <Route
                                        path="/admin/Backmanage/UserManage"
                                        component={UserManage}
                                    />
                                    <Route
                                        path="/admin/PersonalCenter"
                                        component={PersonalCenter}
                                    />
                                    <Route
                                        path="/admin/SpecialCustomized"
                                        render={() => (
                                            <h1
                                                style={{
                                                    margin: '100px auto',
                                                    textAlign: 'center'
                                                }}>
                                                宣传位
                                            </h1>
                                        )}
                                    />
                                    <Route
                                        path="/admin/NullPage"
                                        component={NullPage}
                                    />
                                </Switch>
                            </Admin>
                        )}
                    />
                </App>
            </HashRouter>
        );
    }
}
